package com.jeeplus.cms.support.validation;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * @author Sawyer
 * @date 2020-12-15
 */
@Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER})
@Retention(RUNTIME)
@Documented
@Constraint(validatedBy = {PatternExtendImpl.class})
public @interface PatternExtend {

    /**
     * 是否必须，默认为false
     */
    boolean required() default false;

    /**
     * 正则表达式
     */
    String regexp() default "";

    /**
     * 错误消息
     */
    String message() default "{javax.validation.constraints.Pattern.message}";

    /**
     * 组别
     */
    Class<?>[] groups() default {};

    /**
     * @return the payload associated to the constraint
     */
    Class<? extends Payload>[] payload() default {};

    @Target({METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER})
    @Retention(RUNTIME)
    @Documented
    @interface List {
        PatternExtend[] value();
    }
}

